import numpy as np
from utils.math_utils import distance

class GameEntity:
    """游戏实体基类"""
    
    def __init__(self, x, y, radius):
        self.x = x
        self.y = y
        self.radius = radius
        self.alive = True
        
    def get_position(self):
        """获取位置"""
        return (self.x, self.y)
        
    def set_position(self, x, y):
        """设置位置"""
        self.x = x
        self.y = y
        
    def distance_to(self, other):
        """计算到另一个实体的距离"""
        return distance(self.get_position(), other.get_position())
        
    def collides_with(self, other):
        """检查是否与另一个实体碰撞"""
        if not self.alive or not other.alive:
            return False
        return self.distance_to(other) <= (self.radius + other.radius)
        
    def update(self, dt):
        """更新状态"""
        pass
        
    def render(self, screen):
        """渲染实体"""
        pass